package com.jdy.haoduoaiteacher.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ycsj.goldmedalnewconcept.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * 
 * @author Hufei
 * 
 */
public class NormalQuestionListAdapter extends BaseAdapter {

  private Context mContext;

  private List<String> questionList = new ArrayList<String>();

  public NormalQuestionListAdapter(List<String> list, Context mContext) {
    super();
    this.questionList = list;
    this.mContext = mContext;
  }

  @Override
  public int getCount() {
    if (questionList == null) {
      return 0;
    } else {
      return this.questionList.size();
    }
  }

  @Override
  public Object getItem(int position) {
    if (questionList == null) {
      return null;
    } else {
      return this.questionList.get(position);
    }
  }

  @Override
  public long getItemId(int position) {
    return position;
  }

  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = LayoutInflater.from(this.mContext).inflate(
          R.layout.normal_question_item, null, false);
      holder.tv_q_content = (TextView) convertView
          .findViewById(R.id.tv_q_content);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.tv_q_content.setText(questionList.get(position));

    return convertView;
  }

  private class ViewHolder {
    TextView tv_q_content;
  }

}
